<!-- DataTables-->
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-bs/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-buttons-bs/css/buttons.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-colreorder-bs/css/colReorder.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-keytable-bs/css/keyTable.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-select-bs/css/select.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-responsive-bs/css/responsive.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-fixedcolumns-bs/css/fixedColumns.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/admin/plugins/datatables.net-fixedheader-bs/css/fixedHeader.bootstrap.min.css">
<div class="page-header clearfix">
    <div class="pull-left">
        <h4 class="mt-0 mb-5">友情链接列表</h4>
        <ol class="breadcrumb mb-0">
            <li><a href="#">在这里可以看到所有友情链接列表</a></li>
        </ol>
    </div>

</div>
<div class="main-content container-fluid">
        <table id="listTable" cellspacing="0" width="100%" class="table table-striped table-bordered">
            <thead>
            <tr>
                <th width="3%">#</th>
                <th width="20%">网站名称</th>
                <th width="20%">网站图标</th>
                <th width="15%">链接</th>
                <th width="15%">状态</th>
                <th >操作</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td></td>
                <td></td>
                <td>2107新款式</td>
                <td>118</td>
                <td>55</td>
                <td>55</td>
            </tr>
            </tbody>
        </table>
</div>
<!-- DataTables-->
<script type="text/javascript" src="/static/admin/plugins/datatables.net/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-buttons/js/buttons.colVis.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-buttons/js/buttons.print.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-buttons/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-colreorder/js/dataTables.colReorder.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-select/js/dataTables.select.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-fixedcolumns/js/dataTables.fixedColumns.min.js"></script>
<script type="text/javascript" src="/static/admin/plugins/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
<script>
    var draw = '';
    $(function () {
            draw = $("#listTable").dataTable({
            bPaginate  : true,
            bFilter    : true,
            bSort      : false,
            processing : true,
            serverSide : true,
            ajax       : {
                url: "{:url('admin/link/index')}",
                type: "POST"
            },
            columns:[
                {
                    data : 'id'
                },
                {
                    data : 'name'
                },
                {
                    data : 'thumb'
                },
                {
                    data : 'url'
                },
                {
                    data : 'row_status'
                },
                {
                    data : 'sid'
                }
            ],
            columnDefs:[
                {
                    targets: 2,
                    render: function (data, type, row, meta) {
                        return '<img src="'+row.thumb+'" height="50">';
                    }
                },
                {
                    targets: 4,
                    render: function (data, type, row, meta) {
                        if(row.row_status==0){
                            return '待审核';
                        }else if(row.row_status==1){
                            return '审核通过';
                        }else{
                            return '已拒绝';
                        }
                    }
                },
                {
                    targets: 5,
                    render: function (data, type, row, meta) {
                        return '<a class="btn btn-xs btn-info" href="#" onclick=editData(' + row.sid + ') ><i class="ti-pencil-alt"></i> 修改</a>  ' +
                            '<a class="btn btn-xs btn-danger" href="#" onclick=delData(' + row.sid + ') ><i class="ti-close"></i> 删除</a>';
                    }
                }
            ],
            oLanguage  : {
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                }
            }
        });
    });

    function editData(id) {
        page.go("{:url('admin/link/edit')}?id="+id);
    }

    function delData(id) {
        layer.confirm('你真的要删除此条数据么?',{icon:3,title:'删除提醒'},function () {
            Pace.start();
            $.post('{:url("admin/link/del")}',{id:id},function (data) {
                if(data.err){
                    layer.msg(data.msg,{
                        icon:2,
                        time:1000
                    });
                    return false;
                }
                layer.msg(data.msg,{
                    icon:2,
                    time:1000
                });

                draw.fnDraw(false);

            },'json');
        });

    }
</script>